{include file="header/index" /}
<div class="newContentBox">
    <form action="" class="layui-form">
        <div class="newForm">
            <div class="newGroup">
                <div class="newLabel inputText">注册时间</div>
                <div class="newGroupInput">
                    <input type="text" id="startDate"  placeholder="开始时间" readonly class="layui-input cover_layui_i newDate">
                </div>
            </div>
            <div class="newGroup">
                <div class="newLabel inputText">至</div>
                <div class="newGroupInput">
                    <input type="text" id="endDate" placeholder="结束时间" readonly class="layui-input cover_layui_i newDate">
                </div>
            </div>
            <div class="newGroup">
                <div class="newLabel inputText">用户类型</div>
                <div class="newGroupInput">
                    <select id="user_class" name="user_class" class="layui-input cover_layui_i" lay-filter="aihao">
                        <option value="">全部</option>
                        <option value="3" >未认证</option>
                        <option value="1">个人用户</option>
                        <option value="2">企业用户</option>
                    </select>
                </div>
            </div>
            <div class="newGroup">
                <div class="newLabel inputText">用户账号</div>
                <div class="newGroupInput">
                    <input type="text"  placeholder="开始时间"  class="layui-input cover_layui_i">
                </div>
            </div>
            <div class="newGroup">
                <div class="newLabel inputText">联系电话</div>
                <div class="newGroupInput">
                    <input type="text"  placeholder="开始时间"  class="layui-input cover_layui_i">
                </div>
            </div>
            <div class="newGroup">
                <div class="newLabel inputText">用户姓名</div>
                <div class="newGroupInput">
                    <input type="text"  placeholder="开始时间"  class="layui-input cover_layui_i">
                </div>
            </div>
            <div class="newGroup">
                <div class="newLabel inputText">是否有区域</div>
                <div class="newGroupInput" >
                    <select id="is_a_id" name="is_a_id" class="layui-input cover_layui_i">
                        <option value="">全部</option>
                        
                        <option value="1" >有</option>
                        <option value="2" >没有</option>
                        
                    </select>
                </div>
            </div>
    
            <div class="newGroup newBtnBox">
                <button type="button" id="search" class="newBtnDefault newBtnPrimary">搜索</button>
                <button type="button" id="reset" class="newBtnDefault">重置</button>
            </div>
    
        </div>
    </form>
    <!-- 分割部分 -->
    <div class="newDivision"></div>
    <div class="newListPart">
        <div class="newTitleBox">
            <span class="layui-inline newListTitle">员工列表</span>
            <div class="layui-inline newTitleBtnBox">
                <button type="button" class="newBtnDefault newBtnGray" onclick="refresh()"><i class="fa fa-undo"></i>刷新</button>
            </div>
        </div>
        <div class="newTableBox">
            <table class="layui-table">
                <thead>
                    <tr>
                        <th><input type="checkbox" onclick="checkAll(this)" id="all" /></th>
                        <th>昵称</th>
                        <th>加入时间</th>
                        <th>签名</th>
                        <th>操作</th>
                    </tr> 
                </thead>
                <!--套数据 laypage-->
                <script id="list-template" type="text/html">
                    {{# for(var i=0;i<d.length;i++){  }}
                    <tr>
                        <td><input class="select" type="checkbox" name="box" value="" onclick="selectAll()" /></td>
                        <td>{{d[i].realname}}</td>
                        <td>{{d[i].telphone}}</td>
                        <td>{{d[i].contract_no}}</td>
                        <td>{{d[i].status_name}}</td>
                        <td>
                            <a href="{:url('Workers/detail')}" class="newBtnDefault">详情</a>
                        </td>
                    </tr>
                    {{# } }}
                </script>
                <tbody id="list-content">
                </tbody>
            </table>
            <div class="pageBox">
                <span>批量删除</span>
                <div class="newPage" id="page"></div>
            </div>
            

        </div>

    </div>
</div>


<!--审核弹窗-->
<!-- <form class="layui-form popBox" action="" method="post" id="examineLayer" >
    <div class="popChoose">
        <div class="leftPop">处理状态</div>
        <div class="rightPop">
            <div class="selectBox">
                <select id="user_class" name="user_class">
                        <option value="">请选择状态</option>
                        <option value="3" >无效订单</option>
                        <option value="1">问题已处理</option>
                        <option value="2">问题未处理</option>
                </select>
            </div>
        </div>
    </div>
    <div class="layui-form-item cover_layui_f_i">
        <label class="layui-form-label cover_layui_f_l"><span class="cover_new_label">*</span> select框</label>
        <div class="layui-input-block cover_layui_i_b">
            <select name="" id="">
                <option value="1">选择一</option>
                <option value="2">选择二</option>
                <option value="3">选择三</option>									
            </select>
        </div>
    </div>
    <div class="popChoose">
        <div class="leftPop">处理输入</div>
        <div class="rightPop">
            <div class="selectBox">
                <input class="layui-input" type="text" value="1111">
            </div>
        </div>
    </div>
    <div class="popChoose">
        <div class="leftPop">备注</div>
        <div class="rightPop">
            <textarea placeholder="请输入内容" class="layui-textarea" id="textContent"></textarea>
        </div>
    </div>
</form> -->
<script>
    var layer = layui.layer,
        element = layui.element,
        laydate = layui.laydate,
        laypage = layui.laypage,
        form = layui.form,
        laytpl = layui.laytpl;

    form.render();
    // 开始时间
    laydate.render({
        elem: '#startDate',
    });
    // 结束时间
    laydate.render({
        elem: '#endDate',
    });
    Ajaxpage();
    function Ajaxpage(curr){
        var loadingFlag= layer.msg('正在读取数据，请稍候……', { icon: 16, shade: 0.01,shadeClose:false,time:60000 });
        console.log('curr')
        $.getJSON('{:url("Workorder/index")}',
            {
                page: curr || 1,
            }, function(data){
                console.log(data);
                layer.close(loadingFlag);
                if(data.count==0){
                    $("#list-content").html('<td colspan="20" style="padding-top:10px;padding-bottom:10px;font-size:16px;text-align:center">暂无数据</td>');
                }else{
                    var tpl = document.getElementById('list-template').innerHTML;

                    laytpl(tpl).render(data.data, function(html){
                        console.log('html',html);
                        document.getElementById('list-content').innerHTML = html;
                    });
                    laypage.render({
                        elem: 'page' //注意，这里的 test1 是 ID，不用加 # 号
                        ,count: data.count //数据总数，从服务端得到
                        ,limit: data.pageSize
                        ,curr: curr || 1
                        ,prev: '上一页'//上一页
                        ,next: '下一页'//下一页
                        ,first: '首页'//首页
                        ,last: '尾页'//尾页
                        ,layout: ['count','prev', 'page', 'next','skip']
                        ,jump: function(obj, first) {
                            //页数跳转
                            //obj包含了当前分页的所有参数，比如：
                            console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                            console.log(obj.limit); //得到每页显示的条数
                            //首次不执行
                            if(!first){
                                //do something
                                Ajaxpage(obj.curr);
                            }
                        }

                    });
                }
            });
    }


    //复选框选中
	function checkAll(obj) {
		//alert(obj.checked);
		//获取name=box的复选框
		var userids = document.getElementsByName("box");
		//alert(userids.length);
		for(var i = 0; i < userids.length; i++) {
			userids[i].checked = obj.checked;
		}
	}
    function selectAll() {
		//获取name=box的复选框
		var userids = document.getElementsByName("box");
		var count = 0;
		//遍历所有的复选框
		for(var i = 0; i < userids.length; i++) {
			if(userids[i].checked) {
				count++;
			}
		}
		//选中复选框的个数==获取复选框的个数 
		if(count == userids.length) {
			//设置id为all复选框选中
			document.getElementById("all").checked = true;
		} else {
			//设置id为all复选框不选中
			document.getElementById("all").checked = false;
		}
	}
</script>
